package com.enzoism.manual.springboot.controller;

import com.enzoism.manual.springboot.model.Dept;
import com.enzoism.manual.springboot.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: SpringCloud
 * @description: 部门工具类
 * @author:
 * zhifeng
 * @create: 2020-12-07 14:08
 */
@RestController
@RequestMapping("dept")
public class DeptController {

    @Autowired
    DeptService deptService;

    @PutMapping("/delete/{deptno}")
    public int deleteByPrimaryKey(@PathVariable Long deptno){
        return deptService.deleteByPrimaryKey(deptno);
    }

    @PostMapping("/add")
    public int insert(Dept record){
        return deptService.insert(record);
    }

    @GetMapping("/list")
    public List<Dept> selectList(){
        return deptService.selectList();
    }

    @PostMapping("/insert")
    public int insertSelective(Dept record){
        return deptService.insertSelective(record);
    }

    @GetMapping("/get/{deptno}")
    public Dept selectByPrimaryKey(@PathVariable Long deptno){
        return deptService.selectByPrimaryKey(deptno);
    }

    @GetMapping("/get")
    public String get(@PathVariable Long deptno){
        return "测试";
    }

    @PostMapping("update")
    int updateByPrimaryKeySelective(Dept record){
        return deptService.updateByPrimaryKeySelective(record);
    }

    @PostMapping("edit")
    int updateByPrimaryKey(Dept record){
        return deptService.updateByPrimaryKey(record);
    }
}
